| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var assert = require('chai').assert, |
||
| 73 | it('Create with mixed data', function(){ |
||
| 74 | var agent = GedcomX.Agent({ |
||
| 75 | id: 'agent', |
||
| 76 | identifiers: GedcomX.Identifiers({ |
||
| 77 | $: 'ident' |
||
| 78 | }), |
||
| 79 | names: [ |
||
| 80 | GedcomX.TextValue({ |
||
| 81 | lang: 'en', |
||
| 82 | value: 'Name' |
||
| 83 | }) |
||
| 84 | ], |
||
| 85 | homepage: GedcomX.ResourceReference({ |
||
| 86 | resource: 'http://homepage' |
||
| 87 | }), |
||
| 88 | openid: GedcomX.ResourceReference({ |
||
| 89 | resource: 'http://openid' |
||
| 90 | }), |
||
| 91 | accounts: [ |
||
| 92 | GedcomX.OnlineAccount({ |
||
| 93 | accountName: 'jimbo' |
||
| 94 | }) |
||
| 95 | ], |
||
| 96 | emails: [ |
||
| 97 | GedcomX.ResourceReference({ |
||
| 98 | resource: 'http://email' |
||
| 99 | }) |
||
| 100 | ], |
||
| 101 | phones: [ |
||
| 102 | GedcomX.ResourceReference({ |
||
| 103 | resource: 'http://phone' |
||
| 104 | }) |
||
| 105 | ], |
||
| 106 | addresses: [ |
||
| 107 | GedcomX.Address({ |
||
| 108 | value: 'big long address', |
||
| 109 | postalCode: '123456' |
||
| 110 | }) |
||
| 111 | ], |
||
| 112 | person: GedcomX.ResourceReference({ |
||
| 113 | resource: 'http://person' |
||
| 114 | }) |
||
| 115 | }); |
||
| 116 | assert.equal(agent.getId(), 'agent'); |
||
| 117 | assert.equal(agent.getIdentifiers().identifiers.$, 'ident'); |
||
| 118 | assert.equal(agent.getNames().length, 1); |
||
| 119 | assert.equal(agent.getNames()[0].getLang(), 'en'); |
||
| 120 | assert.equal(agent.getNames()[0].getValue(), 'Name'); |
||
| 121 | assert.equal(agent.getHomepage().getResource(), 'http://homepage'); |
||
| 122 | assert.equal(agent.getOpenid().getResource(), 'http://openid'); |
||
| 123 | assert.equal(agent.getAccounts().length, 1); |
||
| 124 | assert.equal(agent.getAccounts()[0].getAccountName(), 'jimbo'); |
||
| 125 | assert.equal(agent.getEmails().length, 1); |
||
| 126 | assert.equal(agent.getEmails()[0].getResource(), 'http://email'); |
||
| 127 | assert.equal(agent.getPhones().length, 1); |
||
| 128 | assert.equal(agent.getPhones()[0].getResource(), 'http://phone'); |
||
| 129 | assert.equal(agent.getAddresses().length, 1); |
||
| 130 | assert.equal(agent.getAddresses()[0].getValue(), 'big long address'); |
||
| 131 | assert.equal(agent.getAddresses()[0].getPostalCode(), '123456'); |
||
| 132 | assert.equal(agent.getPerson().getResource(), 'http://person'); |
||
| 133 | }); |
||
| 134 | |||
| 218 | }); |